﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Init.PostInit.PostInitActions {
    import Display.DialogUI.*;
    import Display.*;
    import Classes.announcements.*;
    import flash.external.*;

    public class AnnouncementDialog extends StartupDialogBase {

        private var m_data:AnnouncementData;

        public function AnnouncementDialog(_arg1:AnnouncementData, _arg2:Function=null, _arg3:Boolean=true, _arg4:Boolean=false){
            var _local5:String;
            this.m_data = _arg1;
            if (this.m_data.view.hasOwnProperty("multiLang")){
                _local5 = this.getMultiLangMessage(this.m_data);
            } else {
                if (this.m_data.view.hasOwnProperty("otherLang")){
                    _local5 = this.getOtherLangMessage(this.m_data);
                } else {
                    _local5 = ZLoc.t("Announcements", this.m_data.view.text);
                };
            };
            var _local6:String = ZLoc.t("Announcements", this.m_data.view.title);
            var _local7:String = (this.m_data.view.acceptButtonLoc) ? this.m_data.view.acceptButtonLoc : "Okay";
            var _local8:GenericPictureDialog = new GenericPictureDialog(_local5, "", GenericPopup.TYPE_OK, _arg2, _local6, "", true, 0, _local7, this.m_data.view.picUrl);
            super(_local8, this.m_data.view.title, _arg4, this.onAnnouncementSeen, _arg3);
        }
        protected function onAnnouncementSeen():void{
            if (this.m_data){
                this.m_data.setAsSeen();
            };
        }
        protected function getMultiLangMessage(_arg1:AnnouncementData):String{
            var _local2:String = Global.localizer.langCode;
            var _local3:String = Global.player.snUser.locale.split("_")[0];
            var _local4:Array = ExternalInterface.call("getSupportedLanguages");
            if (((((_local4) && (!((_local2 == ""))))) && (!((_local3 == ""))))){
                if (((!((_local4.indexOf(_local3) == -1))) && (!((_local2 == _local3))))){
                    return (((_arg1.view[("text_" + _local2)] + "\n") + _arg1.view[("text_" + _local3)]));
                };
            };
            return (_arg1.view[("text_" + _local2)]);
        }
        protected function getOtherLangMessage(_arg1:AnnouncementData):String{
            var _local2:String = Global.localizer.langCode;
            var _local3:String = Global.player.snUser.locale.split("_")[0];
            var _local4:String = ZLoc.t("Announcements", _arg1.view.text);
            if (_local2 == _local3){
                return (_local4);
            };
            if (_local2 != "en"){
                return (_local4);
            };
            var _local5:String = ("text_" + _local3);
            if (_arg1.view.hasOwnProperty(_local5)){
                _local4 = ((_local4 + "\n") + _arg1.view[_local5]);
            };
            return (_local4);
        }

    }
}//package Init.PostInit.PostInitActions 
